﻿@model IList<CNDreams.Entity.SysMenu>
@{
	ViewBag.Title = "SysMenuManageIndex";
    Layout = "~/Views/Shared/_LayoutEmbeddedFrame.cshtml";
}
<style type="text/css">
	#tree
	{
		float: left;
		height: 100%;
		margin: 1px 0 0 0;
		width: 200px;
		background: url("/Content/images/treebg.jpg") no-repeat scroll 0 0 #FFFFFF;
		padding: 10px 0 0 0;
		overflow:auto;
	}
</style>
<script type="text/javascript">
	$(function () {
		$("#tree").height($("html").height()-18);

		/* 初始化树
		----------------------------------------------------------*/
		var tree = $("#tree").jstree({
			"types": {
				"valid_children": ["root"],
				"types": {
					"root": {
						"icon": {
						    "image": "/Content/images/ico0.jpg"
						},
						"valid_children": ["default"],
						"max_depth": 2,
						"hover_node": false,
						"select_node": function () { }
					},
					"levelOne": {
						"icon": {
						    "image": "/Content/images/ico3.jpg"
						}
					},
					"levelTow": {
						"icon": {
						    "image": "/Content/images/ico4.jpg"
						}
					}
				}
			},
			"plugins": ["themes", "html_data", "ui", "types"]
		});
		tree.bind("loaded.jstree", function (event, data) {
			tree.jstree("open_all");
		});

	});

	function setFrameUrl(url) {
	    $("#embeddedFrame").attr("src", url);
	}
</script>

<div id="tree">
	<ul>
		<li rel="root"><a href="javascript:void(0)" onclick="setFrameUrl('/ModuleSys/SysMenuManage/Index')">
			所有菜单</a>
			<ul>
				@foreach (var item in Model.Where(x => x.Level == 1))
	{
					<li rel="levelOne"><a href="javascript:void(0)" onclick="setFrameUrl('/ModuleSys/SysMenuManage/Index/?menuID=@item.ID')">
						@item.Name
					</a>
						<ul>
							@foreach (var item1 in Model.Where(x => x.Level == 2 && x.ParentID == item.ID))
	   {
								<li rel="levelTow"><a href="javascript:void(0)" onclick="setFrameUrl('/ModuleSys/SysMenuManage/Index/?menuID=@item1.ID')">
									@item1.Name
								</a></li>
	   }
						</ul>
					</li>
       	
	}
			</ul>
		</li>
	</ul>
</div>

